home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / russell / gc32.lha / README < prev    next >
Text File  |  1993-07-29  |  33KB  |  637 lines

  1. Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
  2. Copyright (c) 1991-1993 by Xerox Corporation.  All rights reserved.
  3.  
  4. THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
  5. OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
  6.  
  7. Permission is hereby granted to copy this garbage collector for any purpose,
  8. provided the above notices are retained on all copies.
  9.  
  10.  
  11. This is version 3.2.  Note that functions were renamed since version 1.9
  12. to make naming consistent with PCR collectors.
  13.  
  14. HISTORY -
  15.  
  16.   Early versions of this collector were developed as a part of research
  17. projects supported in part by the National Science Foundation
  18. and the Defense Advance Research Projects Agency.
  19. The SPARC specific code was contributed by Mark Weiser
  20. (weiser@parc.xerox.com).  The Encore Multimax modifications were supplied by
  21. Kevin Kenny (kenny@m.cs.uiuc.edu).  The adaptation to the RT is largely due
  22. to Vernon Lee (scorpion@rice.edu), on machines made available by IBM.
  23. Much of the HP specific code and a number of good suggestions for improving the
  24. generic code are due to Walter Underwood (wunder@hp-ses.sde.hp.com).
  25. Robert Brazile (brazile@diamond.bbn.com) originally supplied the ULTRIX code.
  26. Al Dosser (dosser@src.dec.com) and Regis Cridlig (Regis.Cridlig@cl.cam.ac.uk)
  27. subsequently provided updates and information on variation between ULTRIX
  28. systems.  Parag Patel (parag@netcom.com) supplied the A/UX code.
  29. Bill Janssen (janssen@parc.xerox.com) supplied the SunOS dynamic loader
  30. specific code. Manuel Serrano (serrano@cornas.inria.fr) supplied linux and
  31. Sony News specific code.  Al Dosser provided Alpha/OSF/1 code.  He and
  32. Dave Detlefs(detlefs@src.dec.com) also provided several generic bug fixes.
  33. David Chase, then at Olivetti Research, suggested several improvements.
  34. (Blame for misinstallation of these modifications goes to the first author,
  35. however.)
  36.  
  37.   Much of the code was rewritten by Hans-J. Boehm at Xerox PARC.
  38.  
  39.   This is intended to be a general purpose, garbage collecting storage
  40. allocator.  The algorithms used are described in:
  41.  
  42. Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment",
  43. Software Practice & Experience, September 1988, pp. 807-820.
  44.  
  45. Boehm, H., A. Demers, and S. Shenker, "Mostly Parallel Garbage Collection",
  46. Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Design
  47. and Implementation, SIGPLAN Notices 26, 6 (June 1991), pp. 157-164.
  48.  
  49. Boehm, H., "Space Efficient Conservative Garbage Collection", Proceedings
  50. of the ACM SIGPLAN '91 Conference on Programming Language Design and
  51. Implementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206.
  52.  
  53.   Unlike the collector described in the second reference, this collector
  54. operates either with the mutator stopped during the entire collection
  55. (default) or incrementally during allocations.  (The latter is supported
  56. on only a few machines.)  It does not rely on threads, but is intended
  57. to be thread-safe.
  58.  
  59.   Some of the ideas underlying the collector have previously been explored
  60. by others.  (Doug McIlroy wrote a vaguely similar collector that is part of
  61. version 8 UNIX (tm).)  However none of this work appears to have been widely
  62. disseminated.
  63.  
  64.   Rudimentary tools for use of the collector as a leak detector are included.
  65.  
  66.  
  67. GENERAL DESCRIPTION
  68.  
  69.   This is a garbage colecting storage allocator that is intended to be
  70. used as a plug-in replacement for C's malloc.
  71.  
  72.   Since the collector does not require pointers to be tagged, it does not
  73. attempt to ensure that all inaccessible storage is reclaimed.  However,
  74. in our experience, it is typically more successful at reclaiming unused
  75. memory than most C programs using explicit deallocation.  Unlike manually
  76. introduced leaks, the amount of unreclaimed memory typically stays
  77. bounded.
  78.  
  79.   In the following, an "object" is defined to be a region of memory allocated
  80. by the routines described below.  
  81.  
  82.   Any objects not intended to be collected must be pointed to either
  83. from other such accessible objects, or from the registers,
  84. stack, data, or statically allocated bss segments.  Pointers from
  85. the stack or registers may point to anywhere inside an object.
  86. However, it is usually assumed that all pointers originating in the
  87. heap point to the beginning of an object.  (This does
  88. not disallow interior pointers; it simply requires that there must be a
  89. pointer to the beginning of every accessible object, in addition to any
  90. interior pointers.)  There are two facilities for altering this behavior.
  91. The macro ALL_INTERIOR_POINTERS may be defined in gc_private.h to
  92. cause any pointer into an object to retain the object.  A routine
  93. GC_register_displacement is provided to allow for more controlled
  94. interior pointer use in the heap.  Defining ALL_INTERIOR_POINTERS
  95. is somewhat dangerous.  See gc_private.h for details.  The routine
  96. GC_register_displacement is described in gc.h.
  97.  
  98.   Note that pointers inside memory allocated by the standard "malloc" are not
  99. seen by the garbage collector.  Thus objects pointed to only from such a
  100. region may be prematurely deallocated.  It is thus suggested that the
  101. standard "malloc" be used only for memory regions, such as I/O buffers, that
  102. are guaranteed not to contain pointers.  Pointers in C language automatic,
  103. static, or register variables, are correctly recognized.
  104.  
  105.   The collector does not generally know how to find pointers in data
  106. areas that are associated with dynamic libraries.  This is easy to
  107. remedy IF you know how to find those data areas on your operating
  108. system (see GC_add_roots).  Code for doing this under SunOS4.X only is
  109. included (see dynamic_load.c).  (Note that it includes a special version
  110. of dlopen, GC_dlopen, that should be called instead of the standard one.
  111. By default, this is not compiled in, since it requires the -ldl library.)
  112. Note that the garbage collector does not need to be informed of shared
  113. read-only data.  However if the shared library mechanism can introduce
  114. discontiguous data areas that may contain pointers, then the collector does
  115. need to be informed.
  116.  
  117.   Signal processing for most signals is normally deferred during collection,
  118. and during uninterruptible parts of the allocation process.  Unlike
  119. standard ANSI C mallocs, it is intended to be safe to invoke malloc
  120. from a signal handler while another malloc is in progress, provided
  121. the original malloc is not restarted.  (Empirically, many UNIX
  122. applications already asssume this.)  The allocator/collector can
  123. also be configured for thread-safe operation.  (Full signal safety can
  124. also be acheived, but only at the cost of two system calls per malloc,
  125. which is usually unacceptable.)
  126.  
  127. INSTALLATION AND PORTABILITY
  128.  
  129.   As distributed, the macro SILENT is defined in Makefile.
  130. In the event of problems, this can be removed to obtain a moderate
  131. amount of descriptive output for each collection.
  132. (The given statistics exhibit a few peculiarities.
  133. Things don't appear to add up for a variety of reasons, most notably
  134. fragmentation losses.  These are probably much more significant for the
  135. contrived program "test.c" than for your application.)
  136.  
  137.   Note that typing "make test" will automatically build the collector
  138. and then run setjmp_test and gctest. Setjmp_test will give you information
  139. about configuring the collector, which is useful primarily if you have
  140. a machine that's not already supported.  Gctest is a somewhat superficial
  141. test of collector functionality.  Failure is indicated by a core dump or
  142. a message to the effect that the collector is broken.  Gctest takes about 
  143. 20 seconds to run on a SPARCstation 2. On a slower machine,
  144. expect it to take a while.  It may use up to 8 MB of memory.  (The
  145. multi-threaded version will use more.)
  146.  
  147.   The Makefile will generate a library gc.a which you should link against.
  148. It is suggested that if you need to replace a piece of the collector
  149. (e.g. GC_mark_roots.c) you simply list your version ahead of gc.a on the
  150. ld command line, rather than replacing the one in gc.a.  (This will
  151. generate numerous warnings under some versions of AIX, but it still
  152. works.)
  153.  
  154.   The collector currently is designed to run essentially unmodified on
  155. the following machines:
  156.  
  157.         Sun 3
  158.         Sun 4 under SunOS 4.X or Solaris2.X
  159.         Vax under 4.3BSD, Ultrix
  160.         Intel 386 or 486 under OS/2 (no threads) or linux.
  161.         Sequent Symmetry  (no concurrency)
  162.         Encore Multimax   (no concurrency)
  163.         MIPS M/120 (and presumably M/2000) (RISC/os 4.0 with BSD libraries)
  164.         IBM PC/RT  (Berkeley UNIX)
  165.         IBM RS/6000
  166.         HP9000/300
  167.         HP9000/700
  168.         DECstations under Ultrix
  169.         SGI workstations under IRIX
  170.         Sony News
  171.         Apple MacIntosh under A/UX
  172.  
  173.   For these machines you should check the beginning of gc.h
  174. to verify that the machine type is correctly defined.  On 
  175. nonSun machines, you may also need to make changes to the
  176. Makefile, as described by comments there.
  177.  
  178.   Dynamic libraries are completely supported only under SunOS4.X
  179. (and even that support is not functional on the last Sun 3 release).
  180. On other machines we recommend that you do one of the following:
  181.  
  182.   1) Add dynamic library support (and send us the code).
  183.   2) Use static versions of the libraries.
  184.   3) Arrange for dynamic libraries to use the standard malloc.
  185.      This is still dangerous if the library stores a pointer to a
  186.      garbage collected object.  But nearly all standard interfaces
  187.      prohibit this, because they deal correctly with pointers
  188.      to stack allocated objects.  (Strtok is an exception.  Don't
  189.      use it.)
  190.  
  191.   In all cases we assume that pointer alignment is consistent with that
  192. enforced by the standard C compilers.  If you use a nonstandard compiler
  193. you may have to adjust the alignment parameters defined in gc_private.h.
  194.  
  195.   A port to a machine that is not byte addressed, or does not use 32 bit
  196. addresses will require a major effort.  (Parts of the code try to anticipate
  197. 64 bit addresses.  Others will need to be rewritten, since different data
  198. structures are needed.)  A port to MSDOS is hopeless, unless you are willing
  199. to assume an 80386 or better, and that only flat 32 bit pointers will ever be
  200. used.
  201.  
  202.   For machines not already mentioned, or for nonstandard compilers, the
  203. following are likely to require change:
  204.  
  205. 1.  The parameters at the top of gc_private.h.
  206.       The parameters that will usually require adjustment are
  207.    STACKBOTTOM,  ALIGNMENT and DATASTART.  Setjmp_test
  208.    prints its guesses of the first two.
  209.       DATASTART should be an expression for computing the
  210.    address of the beginning of the data segment.  This can often be
  211.    &etext.  But some memory management units require that there be
  212.    some unmapped space between the text and the data segment.  Thus
  213.    it may be more complicated.   On UNIX systems, this is rarely
  214.    documented.  But the adb "$m" command may be helpful.  (Note
  215.    that DATASTART will usually be a function of &etext.  Thus a
  216.    single experiment is usually insufficient.)
  217.      STACKBOTTOM is used to initialize GC_stackbottom, which
  218.    should be a sufficient approximation to the coldest stack address.
  219.    On some machines, it is difficult to obtain such a value that is
  220.    valid across a variety of MMUs, OS releases, etc.  A number of
  221.    alternatives exist for using the collector in spite of this.  See the
  222.    discussion in gc_private.h immediately preceding the various
  223.    definitions of STACKBOTTOM.
  224.    
  225. 2.  mach_dep.c.
  226.       The most important routine here is one to mark from registers.
  227.     The distributed file includes a generic hack (based on setjmp) that
  228.     happens to work on many machines, and may work on yours.  Try
  229.     compiling and running setjmp_test.c to see whether it has a chance of
  230.     working.  (This is not correct C, so don't blame your compiler if it
  231.     doesn't work.  Based on limited experience, register window machines
  232.     are likely to cause trouble.  If your version of setjmp claims that
  233.     all accessible variables, including registers, have the value they
  234.     had at the time of the longjmp, it also will not work.  Vanilla 4.2 BSD
  235.     makes such a claim.  SunOS does not.)
  236.       If your compiler does not allow in-line assembly code, or if you prefer
  237.     not to use such a facility, mach_dep.c may be replaced by a .s file
  238.     (as we did for the MIPS machine and the PC/RT).
  239.  
  240. 3.  mark_roots.c.
  241.       These are the top level mark routines that determine which sections
  242.     of memory the collector should mark from.  This is normally not
  243.     architecture specific (aside from the macros defined in gc_private.h and
  244.     referenced here), but it can be programming language and compiler
  245.     specific.  The supplied routine should work for most C compilers
  246.     running under UNIX.  Calls to GC_add_roots may sometimes be used
  247.     for similar effect.
  248.  
  249. 4.  The sigsetmask call does not appear to exist under early system V UNIX.
  250.     It is used by the collector to block and unblock signals at times at
  251.     which an asynchronous allocation inside a signal handler could not
  252.     be tolerated.  Under system V, it is possible to remove these calls,
  253.     provided no storage allocation is done by signal handlers.  The
  254.     alternative is to issue a sequence of system V system calls, one per
  255.     signal that is actually used.  This may be a bit slow.
  256.  
  257.   For a different versions of Berkeley UN*X or different machines using the
  258. Motorola 68000, Vax, SPARC, 80386, NS 32000, PC/RT, or MIPS architecture,
  259. it should frequently suffice to change definitions in gc_private.h.
  260.  
  261.  
  262. THE C INTERFACE TO THE ALLOCATOR
  263.  
  264.   The following routines are intended to be directly called by the user.
  265. Note that usually only GC_malloc is necessary.  GC_clear_roots and GC_add_roots
  266. calls may be required if the collector has to trace from nonstandard places
  267. (e.g. from dynamic library data areas on a machine on which the 
  268. collector doesn't already understand them.)  On some machines, it may
  269. be desirable to set GC_stacktop to a good approximation of the stack base. 
  270. (This enhances code portability on HP PA machines, since there is no
  271. good way for the collector to compute this value.)  Client code may include
  272. "gc.h", which defines all of the following, plus a few others.
  273.  
  274. 1)  GC_malloc(nbytes)
  275.     - allocate an object of size nbytes.  Unlike malloc, the object is
  276.       cleared before being returned to the user.  Gc_malloc will
  277.       invoke the garbage collector when it determines this to be appropriate.
  278.       GC_malloc may return 0 if it is unable to acquire sufficient
  279.       space from the operating system.  This is the most probable
  280.       consequence of running out of space.  Other possible consequences
  281.       are that a function call will fail due to lack of stack space,
  282.       or that the collector will fail in other ways because it cannot
  283.       maintain its internal data structures, or that a crucial system
  284.       process will fail and take down the machine.  Most of these
  285.       possibilities are independent of the malloc implementation.
  286.  
  287. 2)  GC_malloc_atomic(nbytes)
  288.     - allocate an object of size nbytes that is guaranteed not to contain any
  289.       pointers.  The returned object is not guaranteed to be cleeared.
  290.       (Can always be replaced by GC_malloc, but results in faster collection
  291.       times.  The collector will probably run faster if large character
  292.       arrays, etc. are allocated with GC_malloc_atomic than if they are
  293.       statically allocated.)
  294.  
  295. 3)  GC_realloc(object, new_size)
  296.     - change the size of object to be new_size.  Returns a pointer to the
  297.       new object, which may, or may not, be the same as the pointer to
  298.       the old object.  The new object is taken to be atomic iff the old one
  299.       was.  If the new object is composite and larger than the original object,
  300.       then the newly added bytes are cleared (we hope).  This is very likely
  301.       to allocate a new object, unless MERGE_SIZES is defined in gc_private.h.
  302.       Even then, it is likely to recycle the old object only if the object
  303.       is grown in small additive increments (which, we claim, is generally bad
  304.       coding practice.)
  305.  
  306. 4)  GC_free(object)
  307.     - explicitly deallocate an object returned by GC_malloc or
  308.       GC_malloc_atomic.  Not necessary, but can be used to minimize
  309.       collections if performance is critical.
  310.  
  311. 5)  GC_expand_hp(number_of_4K_blocks)
  312.     - Explicitly increase the heap size.  (This is normally done automatically
  313.       if a garbage collection failed to GC_reclaim enough memory.  Explicit
  314.       calls to GC_expand_hp may prevent unnecessarily frequent collections at
  315.       program startup.)
  316.       
  317. 6)  GC_clear_roots()
  318.     - Reset the collectors idea of where static variables containing pointers
  319.       may be located to the empty set of locations.  No statically allocated
  320.       variables will be traced from after this call, unless there are
  321.       intervening GC_add_roots calls.  The collector will still trace from
  322.       registers and the program stack.
  323.       
  324. 7)  GC_add_roots(low_address, high_address_plus_1)
  325.     - Add [low_address, high_address) as an area that may contain root pointers
  326.       and should be traced by the collector.  The static data and bss segments
  327.       are considered by default, and should not be added unless GC_clear_roots
  328.       has been called.  The number of root areas is currently limited to 50.
  329.       This is intended as a way to register data areas for dynamic libraries,
  330.       or to replace the entire data ans bss segments by smaller areas that are
  331.       known to contain all the roots. 
  332.  
  333. 8) Several routines to allow for registration of finalization code.
  334.    User supplied finalization code may be invoked when an object becomes
  335.    unreachable.  To call (*f)(obj, x) when obj becomes inaccessible, use
  336.     GC_register_finalizer(obj, f, x, 0, 0);
  337.    For more sophisticated uses, and for finalization ordering issues,
  338.    see gc.h.
  339.  
  340.   The global variable GC_free_space_divisor may be adjusted up from its
  341. default value of 4 to use less space and more collection time, or down for
  342. the opposite effect.  Setting it to 1 or 0 will effectively disable collections
  343. and cause all allocations to simply grow the heap.
  344.  
  345.   The variable GC_non_gc_bytes, which is normally 0, may be changed to reflect
  346. the amount of memory allocated by the above routines that should not be
  347. considered as a candidate for collection.  Careless use may, of course, result
  348. in excessive memory consumption.
  349.  
  350.   Some additional tuning is possible through the parameters defined
  351. near the top of gc_private.h.
  352.   
  353.   If only GC_malloc is intended to be used, it might be appropriate to define:
  354.  
  355. #define malloc(n) GC_malloc(n)
  356. #define calloc(m,n) GC_malloc((m)*(n))
  357.  
  358.   For small pieces of VERY allocation intensive code, gc_inline.h
  359. includes some allocation macros that may be used in place of GC_malloc
  360. and friends.
  361.  
  362.   All externally visible names in the garbage collector start with "GC_".
  363. To avoid name conflicts, client code should avoid this prefix, except when
  364. accessing garbage collector routines or variables.
  365.  
  366.   The internals of the collector understand different object "kinds" (sometimes
  367. called "regions").  By default, the only two kinds are ATOMIC and NORMAL.
  368. Its should be possible to add others, e.g. for data types for which layout
  369. information is known.  The allocation routine "GC_generic_malloc"
  370. takes an explicit kind argument.  (You will probably want to add
  371. faster kind-specific routines as well.) You will need to add another kind
  372. descriptor, including your own mark routine to add a new object kind.
  373. This requires a fairly detailed understanding of at least GC_mark.
  374.  
  375.  
  376. USE AS LEAK DETECTOR:
  377.  
  378.   The collector may be used to track down leaks in C programs that are
  379. intended to run with malloc/free (e.g. code with extreme real-time or
  380. portability constraints).  To do so define FIND_LEAK somewhere in
  381. gc_private.h.  This will cause the collector to invoke the report_leak
  382. routine defined near the top of reclaim.c whenever an inaccessible
  383. object is found that has not been explicitly freed.
  384.   Productive use of this facility normally involves redefining report_leak
  385. to do something more intelligent.  This typically requires annotating
  386. objects with additional information (e.g. creation time stack trace) that
  387. identifies their origin.  Such code is typically not very portable, and is
  388. not included here.
  389.   If all objects are allocated with GC_DEBUG_MALLOC (see next section),
  390. then the default version of report_leak will report the source file
  391. and line number at which the leaked object was allocated.  This may
  392. sometimes be sufficient.
  393.  
  394.  
  395. DEBUGGING FACILITIES:
  396.  
  397.   The routines GC_debug_malloc, GC_debug_malloc_atomic, GC_debug_realloc,
  398. and GC_debug_free provide an alternate interface to the collector, which
  399. provides some help with memory overwrite errors, and the like.
  400. Objects allocated in this way are annotated with additional
  401. information.  Some of this information is checked during garbage
  402. collections, and detected inconsistencies are reported to stderr.
  403.  
  404.   Simple cases of writing past the end of an allocated object should
  405. be caught if the object is explicitly deallocated, or if the
  406. collector is invoked while the object is live.  The first deallocation
  407. of an object will clear the debugging info associated with an
  408. object, so accidentally repeated calls to GC_debug_free will report the
  409. deallocation of an object without debugging information.  Out of
  410. memory errors will be reported to stderr, in addition to returning
  411. NIL.
  412.  
  413.   GC_debug_malloc checking  during garbage collection is enabled
  414. with the first call to GC_debug_malloc.  This will result in some
  415. slowdown during collections.  If frequent heap checks are desired,
  416. this can be acheived by explicitly invoking GC_gcollect, e.g. from
  417. the debugger.
  418.  
  419.   GC_debug_malloc allocated objects should not be passed to GC_realloc
  420. or GC_free, and conversely.  It is however acceptable to allocate only
  421. some objects with GC_debug_malloc, and to use GC_malloc for other objects,
  422. provided the two pools are kept distinct.  In this case, there is a very
  423. low probablility that GC_malloc allocated objects may be misidentified as
  424. having been overwritten.  This should happen with probability at most
  425. one in 2**32.  This probability is zero if GC_debug_malloc is never called.
  426.  
  427.   GC_debug_malloc, GC_malloc_atomic, and GC_debug_realloc take two
  428. additional trailing arguments, a string and an integer.  These are not
  429. interpreted by the allocator.  They are stored in the object (the string is
  430. not copied).  If an error involving the object is detected, they are printed.
  431.  
  432.   The macros GC_MALLOC, GC_MALLOC_ATOMIC, GC_REALLOC, GC_FREE, and
  433. GC_REGISTER_FINALIZER are also provided.  These require the same arguments
  434. as the corresponding (nondebugging) routines.  If gc.h is included
  435. with GC_DEBUG defined, they call the debugging versions of these
  436. functions, passing the current file name and line number as the two
  437. extra arguments, where appropriate.  If gc.h is included without GC_DEBUG
  438. defined, then all these macros will instead be defined to their nondebugging
  439. equivalents.  (GC_REGISTER_FINALIZER is necessary, since pointers to
  440. objects with debugging information are really pointers to a displacement
  441. of 16 bytes form the object beginning, and some translation is necessary
  442. when finalization routines are invoked.  For details, about what's stored
  443. in the header, see the definition of the type oh in debug_malloc.c)
  444.  
  445. INCREMENTAL/GENERATIONAL COLLECTION:
  446.  
  447. The collector normally interrupts client code for the duration of 
  448. a garbage collection mark phase.  This may be unacceptable if interactive
  449. response is needed for programs with large heaps.  The collector
  450. can also run in a "generational" mode, in which it usually attempts to
  451. collect only objects allocated since the last garbage collection.
  452. Furthermore, in this mode, garbage collections run mostly incrementally,
  453. with a small amount of work performed in response to each of a large number of
  454. GC_malloc requests.
  455.  
  456. This mode is enabled by a call to GC_enable_incremental().
  457.  
  458. Incremental and generational collection is effective in reducing
  459. pause times only if the collector has some way to tell which objects
  460. or pages have been recently modified.  The collector uses two sources
  461. of information:
  462.  
  463. 1. Information provided by the VM system.  This may be provided in
  464. one of several forms.  Under Solaris 2.X (and potentially under other
  465. similar systems) information on dirty pages can be read from the
  466. /proc file system.  Under other systems (currently SunOS4.X) it is
  467. possible to write-protect the heap, and catch the resulting faults.
  468. On these systems we require that system calls writing to the heap
  469. (other than read) be handled specially by client code.
  470. See os_dep.c for details.
  471.  
  472. 2. Information supplied by the programmer.  We define "stubborn"
  473. objects to be objects that are rarely changed.  Such an object
  474. can be allocated (and enabled for writing) with GC_malloc_stubborn.
  475. Once it has been initialized, the collector should be informed with
  476. a call to GC_end_stubborn_change.  Subsequent writes that store
  477. pointers into the object must be preceded by a call to
  478. GC_change_stubborn.
  479.  
  480. This mechanism performs best for objects that are written only for
  481. initialization, and such that only one stubborn object is writable
  482. at once.  It is typically not worth using for short-lived
  483. objects.  Stubborn objects are treated less efficiently than pointerfree
  484. (atomic) objects.
  485.  
  486. A rough rule of thumb is that, in the absence of VM information, garbage
  487. collection pauses are proportional to the amount of pointerful storage
  488. plus the amount of modified "stubborn" storage that is reachable during
  489. the collection.  
  490.  
  491. Initial allocation of stubborn objects takes longer than allocation
  492. of other objects, since other data structures need to be maintained.
  493.  
  494. We recommend against random use of stubborn objects in client
  495. code, since bugs caused by inappropriate writes to stubborn objects
  496. are likely to be very infrequently observed and hard to trace.  
  497. However, their use may be appropriate in a few carefully written
  498. library routines that do not make the objects themselves available
  499. for writing by client code.
  500.  
  501.  
  502. BUGS:
  503.  
  504.   Any memory that does not have a recognizable pointer to it will be
  505. reclaimed.  Exclusive-or'ing forward and backward links in a list
  506. doesn't cut it.
  507.   Some C optimizers may lose the last undisguised pointer to a memory
  508. object as a consequence of clever optimizations.  This has almost
  509. never been observed in practice.  Send mail to boehm@parc.xerox.com
  510. for suggestions on how to fix your compiler.
  511.   This is not a real-time collector.  In the standard configuration,
  512. percentage of time required for collection should be constant across
  513. heap sizes.  But collection pauses will increase for larger heaps.
  514. (On SPARCstation 2s collection times will be on the order of 300 msecs
  515. per MB of accessible memory that needs to be scanned.  Your mileage
  516. may vary.)  The incremental/generational collection facility helps,
  517. but is portable only if "stubborn" allocation is used.
  518.  
  519. RECENT VERSIONS:
  520.  
  521.   Version 1.3 and immediately preceding versions contained spurious
  522. assembly language assignments to TMP_SP.  Only the assignment in the PC/RT
  523. code is necessary.  On other machines, with certain compiler options,
  524. the assignments can lead to an unsaved register being overwritten.
  525. Known to cause problems under SunOS 3.5 WITHOUT the -O option.  (With
  526. -O the compiler recognizes it as dead code.  It probably shouldn't,
  527. but that's another story.)
  528.  
  529.   Version 1.4 and earlier versions used compile time determined values
  530. for the stack base.  This no longer works on Sun 3s, since Sun 3/80s use
  531. a different stack base.  We now use a straightforward heuristic on all
  532. machines on which it is known to work (incl. Sun 3s) and compile-time
  533. determined values for the rest.  There should really be library calls
  534. to determine such values.
  535.  
  536.   Version 1.5 and earlier did not ensure 8 byte alignment for objects
  537. allocated on a sparc based machine.
  538.  
  539.   Please address bug reports to boehm@xerox.com.  If you are contemplating
  540. a major addition, you might also send mail to ask whether it's already
  541. been done.
  542.  
  543.   Version 1.8 added ULTRIX support in gc_private.h.
  544.   
  545.   Version 1.9 fixed a major bug in gc_realloc.
  546.   
  547.   Version 2.0 introduced a consistent naming convention for collector
  548. routines and added support for registering dynamic library data segments
  549. in the standard mark_roots.c.  Most of the data structures were revamped.
  550. The treatment of interior pointers was completely changed.  Finalization
  551. was added.  Support for locking was added.  Object kinds were added.
  552. We added a black listing facility to avoid allocating at addresses known
  553. to occur as integers somewhere in the address space.  Much of this
  554. was accomplished by adapting ideas and code from the PCR collector.
  555. The test program was changed and expanded.
  556.  
  557.   Version 2.1 was the first stable version since 1.9, and added support
  558. for PPCR.
  559.  
  560.   Version 2.2 added debugging allocation, and fixed various bugs.  Among them:
  561. - GC_realloc could fail to extend the size of the object for certain large object sizes.
  562. - A blatant subscript range error in GC_printf, which unfortunately
  563.   wasn't excercised on machines with sufficient stack alignment constraints.
  564. - GC_register_displacement did the wrong thing if it was called after
  565.   any allocation had taken place.
  566. - The leak finding code would eventually break after 2048 byte
  567.   byte objects leaked.
  568. - interface.c didn't compile.
  569. - The heap size remained much too small for large stacks.
  570. - The stack clearing code behaved badly for large stacks, and perhaps
  571.   on HP/PA machines.
  572.  
  573.   Version 2.3 added ALL_INTERIOR_POINTERS and fixed the following bugs:
  574. - Missing declaration of etext in the A/UX version.
  575. - Some PCR root-finding problems.
  576. - Blacklisting was not 100% effective, because the plausible future
  577.   heap bounds were being miscalculated.
  578. - GC_realloc didn't handle out-of-memory correctly.
  579. - GC_base could return a nonzero value for addresses inside free blocks.
  580. - test.c wasn't really thread safe, and could erroneously report failure
  581.   in a multithreaded environment.  (The locking primitives need to be
  582.   replaced for other threads packages.)
  583. - GC_CONS was thoroughly broken.
  584. - On a SPARC with dynamic linking, signals stayed diabled while the
  585.   client code was running.
  586.   (Thanks to Manuel Serrano at INRIA for reporting the last two.)
  587.   
  588.   Version 2.4 added GC_free_space_divisor as a tuning knob, added
  589.   support for OS/2 and linux, and fixed the following bugs:
  590. - On machines with unaligned pointers (e.g. Sun 3), every 128th word could
  591.   fail to be considered for marking.
  592. - Dynamic_load.c erroneously added 4 bytes to the length of the data and
  593.   bss sections of the dynamic library.  This could result in a bad memory
  594.   reference if the actual length was a multiple of a page.  (Observed on
  595.   Sun 3.  Can probably also happen on a Sun 4.)
  596.   (Thanks to Robert Brazile for pointing out that the Sun 3 version
  597.   was broken.  Dynamic library handling is still broken on Sun 3s
  598.   under 4.1.1U1, but apparently not 4.1.1.  If you have such a machine,
  599.   use -Bstatic.)
  600.   
  601.   Version 2.5 fixed the following bugs:
  602. - Removed an explicit call to exit(1)
  603. - Fixed calls to GC_printf and GC_err_printf, so the correct number of
  604.   arguments are always supplied.  The OS/2 C compiler gets confused if
  605.   the number of actuals and the number of formals differ.  (ANSI C
  606.   doesn't require this to work.  The ANSI sanctioned way of doing things
  607.   causes too many compatibility problems.)
  608.   
  609.   Version 3.0  added generational/incremental collection and stubborn
  610.   objects.
  611.  
  612.   Version 3.1 added the following features:
  613. - A workaround for a SunOS 4.X SPARC C compiler
  614.   misfeature that caused problems when the collector was turned into
  615.   a dynamic library.  
  616. - A fix for a bug in GC_base that could result in a memory fault.
  617. - A fix for a performance bug (and several other misfeatures) pointed
  618.   out by Dave Detelfs and Al Dosser.
  619. - Use of dirty bit information for static data under Solaris 2.X.
  620. - DEC Alpha/OSF1 support (thanks to Al Dosser).
  621. - Incremental collection on more platforms.
  622. - A more refined heap expansion policy.  Less space usage by default.
  623. - Various minor enhancements to reduce space usage, and to reduce
  624.   the amount of memory scanned by the collector.
  625. - Uncollectable allocation without per object overhead.
  626. - More conscientious handling of out-of-memory conditions.
  627. - Fixed a bug in debugging stubborn allocation.
  628. - Fixed a bug that resulted in occasional erroneous reporting of smashed
  629.   objects with debugging allocation.
  630. - Fixed bogus leak reports of size 4096 blocks with FIND_LEAK.
  631.  
  632.   Version 3.2 fixed a serious and not entirely repeatable bug in
  633.   the incremental collector.  It appeared only when dirty bit info
  634.   on the roots was available, which is normally only under Solaris.
  635.   It also added GC_general_register_disappearing_link, and some
  636.   testing code.  Interface.c disappeared.
  637.